//
//  Person_D_two.m
//  K-Music
//
//  Created by CHUN on 16/1/14.
//  Copyright © 2016年 CHUN. All rights reserved.
//

#import "Person_D_two.h"
#import "RecordWork.h"
#import "fans_C2.h"
#import "geyou_C1.h"

#import "me_chorus_D0.h"
#import "MessageVC.h"

@interface Person_D_two ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate>{
    
    
}
@property (nonatomic, strong) UITableView * Person_D_two;

@end

@implementation Person_D_two

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGB(241, 241, 241);
    
    [self createUI];
    
    // Do any additional setup after loading the view.
}

- (void)createUI
{
    _Person_D_two = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-165) style:UITableViewStylePlain];
    _Person_D_two.delegate = self;
    _Person_D_two.dataSource = self;
    _Person_D_two.showsVerticalScrollIndicator = NO;
    _Person_D_two.separatorStyle = UITableViewCellSeparatorStyleNone;
    _Person_D_two.backgroundColor = RGB(241, 241, 241);
    [self.view addSubview:_Person_D_two];
}


#pragma mark ------- UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 8.0f;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    UILabel *iconNameLabel;
    UIImageView *iconView;
    
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
        
        // 图片
        iconView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 12.5, 20, 20)];
        [cell.contentView addSubview:iconView];
        
        iconNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 200, cell.contentView.frame.size.height)];
        
        iconNameLabel.font = [UIFont systemFontOfSize:15.0f];
        iconNameLabel.textAlignment = NSTextAlignmentLeft;
        [cell.contentView addSubview:iconNameLabel];
        
        UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, cell.contentView.frame.size.height-1, WIDTH, 1)];
        lineView2.backgroundColor = [UIColor clearColor];
        [cell.contentView addSubview:lineView2];
        
        if (indexPath.row != 0) {
            UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 1)];
            lineView1.backgroundColor = RGB(241, 241, 241);
            [cell.contentView addSubview:lineView1];
        }
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType  = UITableViewCellAccessoryDisclosureIndicator;
    
    NSArray *iconName0 = @[@"我转发的作品",@"我发起的合唱"];
    NSArray *iconImage0 = @[@"person_01",@"person_02"];
    
    
    NSArray *iconName1 = @[@"我关注的歌友",@"我的粉丝"];
    NSArray *iconImage1 = @[@"person_03",@"person_04"];
    
    NSArray *iconName2 = @[@"我的包房",@"我的群组"];
    NSArray *iconImage2 = @[@"person_07",@"person_08"];

    
    if (indexPath.section == 0) {
        
        iconNameLabel.text = iconName0[indexPath.row];
        iconView.image = [UIImage imageNamed:iconImage0[indexPath.row]];
        
    }
    else if (indexPath.section == 1)
    {
        iconNameLabel.text = iconName1[indexPath.row];
        iconView.image = [UIImage imageNamed:iconImage1[indexPath.row]];
        
    }
    else if (indexPath.section == 2)
    {
        iconNameLabel.text = iconName2[indexPath.row];
        iconView.image = [UIImage imageNamed:iconImage2[indexPath.row]];
        
    }

    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.section) {
        case 0:
            if (indexPath.row ==0 ) {
                RecordWork *recordWork = [RecordWork new];
                [self.navigationController pushViewController:recordWork animated:YES];
                //[MBProgressHUD showErrorWithStatus:@"00" toView:self.view];
            }
            if (indexPath.row ==1 ) {
               
                [self.navigationController pushViewController:[me_chorus_D0 new] animated:YES];
                //[MBProgressHUD showErrorWithStatus:@"01" toView:self.view];
            }
            break;
            
        case 1:
            if (indexPath.row ==0 ) {
                [self.navigationController pushViewController:[geyou_C1 new] animated:YES];
                //[MBProgressHUD showErrorWithStatus:@"10" toView:self.view];
            }
            if (indexPath.row ==1 ) {
               [self.navigationController pushViewController:[fans_C2 new] animated:YES];
                //[MBProgressHUD showErrorWithStatus:@"11" toView:self.view];
            }

            break;
            
        case 2:
            
            if (indexPath.row ==0 ) {
                MessageVC * message = [[MessageVC alloc]init];
                message.title = @"我的包房";
                [self.navigationController pushViewController:message animated:YES];
                //[MBProgressHUD showErrorWithStatus:@"我的包房" toView:self.view];
            }
            if (indexPath.row ==1 ) {
                MessageVC * message = [[MessageVC alloc]init];
                message.title = @"我的群组";
                [self.navigationController pushViewController:message animated:YES];
                //[MBProgressHUD showErrorWithStatus:@"我的群组" toView:self.view];
            }
            break;
            
            
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
